<template>
    <div>
        <van-nav-bar
                title="更改头像"
                left-text="返回"
                left-arrow
                @click-left="onClickLeft"

        />
        <div class="box">
            <van-uploader :after-read="afterRead" />
        </div>
    </div>
</template>

<script>
    import {changeAvatar} from '../api/api'
    import {Toast} from "vant";
    export default {
        name: "ModifyingInformation",
        data(){
          return{

          }
        },
        methods:{
            onClickLeft() {
                this.$router.push({path:'/myapp/user',query:{active:3}});
                // this.$router.push("/myapp/user")
            },


                afterRead(file) {
                    // 此时可以自行将文件上传至服务器
                    changeAvatar(file.file).then(res=>{
                        if(res.code==0){
                            Toast("修改成功");
                            this.$router.push("/myapp/user")
                        }
                        console.log(res)
                        }
                    )

                },

        },
    }
</script>

<style scoped>
    .box{
        height:calc(100vh - 60px);
        display:flex;
        justify-content: center;
        align-items: center;
    }
</style>